//
//  TipClickView.m
//  CedarFinancePH
//
//  Created by lshenrong on 2018/3/30.
//  Copyright © 2018年 cedarhd. All rights reserved.
//

#import "TipClickView.h"

@interface TipClickView()

@property (nonatomic,copy) NSString *tips;
@property (nonatomic,copy) NSString *clickTitle;


@end

@implementation TipClickView

- (instancetype)initWithTips:(NSString *)tips title:(NSString *)title{
    if (self = [super init]) {
        self.tips = tips;
        self.clickTitle = title;
        self.backgroundColor = [UIColor redColor];
        [self initUI];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame tips:(NSString *)tips title:(NSString *)title{
    if (self = [super initWithFrame:frame]) {
        self.tips = tips;
        self.clickTitle = title;
        [self initUI];
    }
    return self;
}


- (void)initUI{
    UILabel *label = [[UILabel alloc]init];
    label.textAlignment = NSTextAlignmentRight;
    MACRO_UILabel_Configure(label, self.tips, kGrayText2Color, 14)
    [self addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self);
        make.centerY.mas_equalTo(self);
        make.width.mas_equalTo(self.mas_width).multipliedBy(0.5);
    }];
    CedarButton *clickBtn = [CedarButton buttonWithTextNoStytle:self.clickTitle];
    [clickBtn PFCGStyleTextColor:kRegisterColor fontSize:14];
    [clickBtn addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:clickBtn];
    [clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(label.mas_right).mas_offset(2);
        make.centerY.mas_equalTo(self);
    }];
}

- (void)clickButton:(UIButton *)button{
    if (self.clickEvent) {
        self.clickEvent();
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
